package entities_testCase;

import java.util.ArrayList;

import junit.framework.TestCase;
import smallTools.SimpleTime;
import entities.Course;
import entities.Room;
import entities.Section;
import entities.Staff;

public class StaffTest extends TestCase {

	private Staff staff1;

	public void setUp() {
		staff1 = new Staff("staffId1");
	}

	public void tearDown() {
		Staff.clear();
		Section.clear();
		Course.clear();
		Room.clear();
	}

	public void test_insertTwice() {
		new Staff("staffId1");
		assertEquals(staff1, Staff.getStaffById("staffId1"));
	}

	public void test_getStaffId_getStaffById() {
		Staff s1 = Staff.getStaffById("staffId1");
		assertEquals("staffId1", s1.getStaffId());
	}

	public void test_addNewSection_getAllSectionIds() {
		Section section1 = new Section("sectionId1", 60, 2, "staffId1");
		Section section2 = new Section("sectionId2", 60, 2, "staffId1");
		staff1.addNewSection("sectionId1");
		staff1.addNewSection("sectionId2");

		ArrayList<String> allSectionIds1 = staff1.getAllSectionIds();
		assertEquals(2, allSectionIds1.size());
		assertEquals("sectionId1", allSectionIds1.get(0));
		assertEquals("sectionId2", allSectionIds1.get(1));

		section1.setSectionStartTime(new SimpleTime("Mon", 11, 30));
		section2.setSectionStartTime(new SimpleTime("Mon", 9, 30));

		ArrayList<String> allSectionIds2 = staff1.getAllSectionIds();
		assertEquals(2, allSectionIds2.size());
		assertEquals("sectionId1", allSectionIds2.get(1));
		assertEquals("sectionId2", allSectionIds2.get(0));
	}
}
